package com.fanjun.learning.multithread.Activity_Object_Pattern;

/**
 * Created by fanjun on 16/10/17.
 */
public class FutureResult extends Result{
    private Result result;
    private boolean ready = false;
    public synchronized Object getValue() {
        while (!ready){
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        return result.getValue();
    }

    public synchronized void setResult(Result result) {
        this.result = result;
        this.ready = true;
        notifyAll();
    }
}
